home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 326-350 / disk_333 / multiplot / source / mplot_src / physio.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  42KB  |  1,058 lines

  1. #include <graphics/display.h>
  2. #include <libraries/dosextens.h>
  3. #include <libraries/diskfont.h>
  4. #include <exec/exec.h>
  5. #include <intuition/intuitionbase.h>
  6. #include <graphics/regions.h>
  7. #include <devices/keymap.h>
  8. #include <stdio.h>
  9. #include <dos.h>
  10. #include <workbench/startup.h>
  11. #include <graphics/gfxmacros.h>
  12. #include <graphics/gfxbase.h>
  13. #include <math.h>
  14.  
  15. #include "struct.h"
  16. #include "plot.h"
  17.  
  18. extern int MAXVERT;
  19. extern int MAXHORIZ;
  20. extern int XMAXP;
  21. extern int XMINP;
  22. extern int YMAXP;
  23. extern int YMINP;
  24. extern struct PlotRegion *FullReg;
  25.  
  26.  
  27. struct Window *OpenWindow();
  28. struct InputEvent *Intuition();
  29. struct Screen *OpenScreen();
  30. int WrtPlt();
  31.  
  32. struct RastPort *rp;
  33. struct ViewPort *vp;
  34. struct Window *window;
  35. struct IntuiMessage *msg;
  36. struct Screen *screen;
  37.  
  38. struct NewScreen newscreen = {
  39.         0,0,                    /* start pos.*/
  40.         MaxHORIZ,MaxVERT,4,     /* width height depth (4 bit planes) */
  41.         2,1,                    /* detail pen, block pen */
  42.         HIRES | LACE,           /* viewing mode (640x400 interlaced) */
  43.         CUSTOMSCREEN,           /* screen type */
  44.         NULL,                   /* font */
  45.         "MultiPlot XLNb                         © AG Baxter & T Mooney 1987 - 1990            ",
  46.         NULL                    /* gadget pointer */
  47.         };
  48.  
  49. struct NewWindow newwindow = {
  50.         0,0,                                    /* Starting corner */
  51.         MaxHORIZ,MaxVERT,                       /* Width, height */
  52.         1,14,                                   /* detail, block pens */
  53.         MENUPICK | MOUSEMOVE | MOUSEBUTTONS,    /* IDCMP flags */
  54.         ACTIVATE | BORDERLESS | NOCAREREFRESH | REPORTMOUSE,
  55.         NULL,                                   /* Pointer to first gadget */
  56.         NULL,                                   /* Pointer to checkmark */
  57.         NULL,                                   /* title */
  58.         NULL,                                   /* screen pointer */
  59.         NULL,                                   /* bitmap pointer */
  60.         0,0,0,0,                                /* sizing limits */
  61.         CUSTOMSCREEN                            /* type of screen */
  62.         };
  63.  
  64. char Def_file[150];
  65. extern char StartDir[150];
  66.  
  67. void InitColours()
  68. {
  69. int depth, i, r, g, b;
  70. FILE *fp;
  71.  
  72.    depth = 1 << screen->BitMap.Depth;   /* no easier way? */
  73.    strmfp(Def_file,StartDir,"MPlot.def");
  74.    if (!(fp = fopen(Def_file,"r")))
  75.       {
  76.          strcpy(Def_file,"s:");
  77.          strcat(Def_file,"MPlot.def");
  78.          fp = fopen(Def_file,"r");
  79.       }
  80.    if (!fp)
  81.       {
  82.           Message("  Can't open file MPlot.def     ");
  83.           SetRGB4(vp,0,15,10,5);   SetRGB4(vp,1,0,0,0);    SetRGB4(vp,2,15,15,15);
  84.           SetRGB4(vp,3,15,0,0);    SetRGB4(vp,4,0,0,0);    SetRGB4(vp,5,15,0,0);
  85.           SetRGB4(vp,6,0,12,0);    SetRGB4(vp,7,0,5,15);   SetRGB4(vp,8,13,13,0);
  86.           SetRGB4(vp,9,0,13,13);   SetRGB4(vp,10,15,0,15); SetRGB4(vp,11,10,10,0);
  87.           SetRGB4(vp,12,8,8,8);    SetRGB4(vp,13,5,5,0);   SetRGB4(vp,14,0,10,15);
  88.           SetRGB4(vp,15,15,8,0);
  89.       }
  90.    else
  91.       {
  92.          for (i=0; (i < depth) && (fscanf(fp,"%d %d %d\n",&r,&g,&b)==3); i++)
  93.            SetRGB4(vp,i,r,g,b);
  94.          fclose(fp);
  95.       }
  96. }
  97.  
  98.  
  99. SvColours()
  100. {
  101. int depth, i, r, g, b;
  102. FILE *fp;
  103. UWORD colour;               /* I only remember these typedefs */
  104. struct ColorMap *map;         /* when reading includes :-) */
  105.  
  106.    depth = 1 << screen->BitMap.Depth;   /* no easier way? */
  107.    map = vp->ColorMap;
  108.  
  109.    strmfp(Def_file,StartDir,"MPlot.def");
  110.  
  111.    if (!(fp = fopen(Def_file,"w")))
  112.       {
  113.          strcpy(Def_file,"s:");
  114.          strcat(Def_file,"MPlot.def");
  115.          fp = fopen(Def_file,"w");
  116.       }
  117.    if (!fp)
  118.       {
  119.           Message("  Can't open file MPlot.def     ");
  120.           return(0);
  121.       }
  122.    for (i=0; i < depth; i++)
  123.      {
  124.         colour = GetRGB4(map,i); /* each colour component encoded by 4 bits */
  125.         r = (colour & 0xf00) >> 8;
  126.         g = (colour & 0x0f0) >> 4;
  127.         b = (colour & 0x00f);
  128.         fprintf(fp,"%d %d %d\n",r,g,b);
  129.      }
  130.    fclose(fp);
  131.    return(1);
  132. }
  133.  
  134.  
  135.  
  136. struct IntuiText MText1b = {
  137.         3,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
  138.         0,0,   /* XY origin relative to container TopLeft */
  139.         NULL,   /* font pointer or NULL for default */
  140.         "Save",     /* pointer to text */
  141.         NULL    /* next IntuiText structure */
  142. };
  143.  
  144. struct MenuItem SaveColours = {
  145.         NULL,      /* next SubItem structure */
  146.         97,16,   /* XY of Item hitbox relative to TopLeft of parent hitbox */
  147.         82,8,   /* hit box width and height */
  148.         ITEMTEXT+ITEMENABLED+HIGHCOMP,  /* Item flags */
  149.         0,      /* each bit mutually-excludes a same-level Item */
  150.         (APTR)&MText1b,  /* Item render  (IntuiText or Image or NULL) */
  151.         NULL,   /* Select render */
  152.         NULL,   /* alternate command-key */
  153.         NULL,   /* no SubItem list for SubItems */
  154.         MENUNULL        /* filled in by Intuition for drag selections */
  155. };
  156. #define SI_SAVECOL 1
  157.  
  158. struct IntuiText MText1a = {
  159.         3,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
  160.         0,0,    /* XY origin relative to container TopLeft */
  161.         NULL,   /* font pointer or NULL for default */
  162.         "Alter",     /* pointer to text */
  163.         NULL    /* next IntuiText structure */
  164. };
  165.  
  166.  
  167. struct MenuItem AlterColours = {
  168.         &SaveColours,   /* next MenuItem structure */
  169.         97,8,  /* XY of Item hitbox relative to TopLeft of parent hitbox */
  170.         82,8,   /* hit box width and height */
  171.         ITEMTEXT+ITEMENABLED+HIGHCOMP,  /* Item flags */
  172.         0,      /* each bit mutually-excludes a same-level Item */
  173.         (APTR)&MText1a,  /* Item render  (IntuiText or Image or NULL) */
  174.         NULL,   /* Select render */
  175.         NULL,   /* alternate command-key */
  176.         NULL,   /* no SubItem list for SubItems */
  177.         MENUNULL        /* filled in by Intuition for drag selections */
  178. };
  179. #define SI_ALTERCOL 0
  180.  
  181. struct IntuiText MText1 = {
  182.         3,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
  183.         0,0,    /* XY origin relative to container TopLeft */
  184.         NULL,   /* font pointer or NULL for default */
  185.         "Palette",     /* pointer to text */
  186.         NULL    /* next IntuiText structure */
  187. };
  188.  
  189. struct MenuItem Palette = {
  190.         NULL,   /* next MenuItem structure */
  191.         0,45,   /* XY of Item hitbox relative to TopLeft of parent hitbox */
  192.         160,8,  /* hit box width and height */
  193.         ITEMTEXT+ITEMENABLED+HIGHCOMP,  /* Item flags */
  194.         0,      /* each bit mutually-excludes a same-level Item */
  195.         (APTR)&MText1,  /* Item render  (IntuiText or Image or NULL) */
  196.         NULL,   /* Select render */
  197.         NULL,    /* alternate command-key */
  198.         &AlterColours,   /* SubItem list */
  199.         MENUNULL        /* filled in by Intuition for drag selections */
  200. };
  201. #define MI_PALETTE 5
  202.  
  203. struct IntuiText MText2 = {
  204.         3,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
  205.         0,0,    /* XY origin relative to container TopLeft */
  206.         NULL,   /* font pointer or NULL for default */
  207.         "Axes", /* pointer to text */
  208.         NULL    /* next IntuiText structure */
  209. };
  210.  
  211. struct MenuItem Axes = {
  212.         &Palette,     /* next MenuItem structure */
  213.         0,36,   /* XY of Item hitbox relative to TopLeft of parent hitbox */
  214.         160,8,  /* hit box width and height */
  215.         ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,  /* Item flags */
  216.         0,      /* each bit mutually-excludes a same-level Item */
  217.         (APTR)&MText2,  /* Item render  (IntuiText or Image or NULL) */
  218.         NULL,   /* Select render */
  219.         'a',    /* alternate command-key */
  220.         NULL,   /* SubItem list */
  221.         MENUNULL        /* filled in by Intuition for drag selections */
  222. };
  223. #define MI_AXES 4
  224.  
  225. struct IntuiText MText3 = {
  226.         3,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
  227.         0,0,    /* XY origin relative to container TopLeft */
  228.         NULL,   /* font pointer or NULL for default */
  229.         "Grid", /* pointer to text */
  230.         NULL    /* next IntuiText structure */
  231. };
  232.  
  233. struct MenuItem Grid = {
  234.         &Axes,     /* next MenuItem structure */
  235.         0,27,   /* XY of Item hitbox relative to TopLeft of parent hitbox */
  236.         160,8,  /* hit box width and height */
  237.         ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,  /* Item flags */
  238.         0,      /* each bit mutually-excludes a same-level Item */
  239.         (APTR)&MText3,  /* Item render  (IntuiText or Image or NULL) */
  240.         NULL,   /* Select render */
  241.         's',    /* alternate command-key */
  242.         NULL,   /* SubItem list */
  243.         MENUNULL        /* filled in by Intuition for drag selections */
  244. };
  245. #define MI_GRID 3
  246.  
  247. struct IntuiText MText4 = {
  248.         3,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
  249.         0,0,    /* XY origin relative to container TopLeft */
  250.         NULL,   /* font pointer or NULL for default */
  251.         "Cross Hair",   /* pointer to text */
  252.         NULL    /* next IntuiText structure */
  253. };
  254.  
  255. struct MenuItem Crosshair = {
  256.         &Grid,     /* next MenuItem structure */
  257.         0,18,   /* XY of Item hitbox relative to TopLeft of parent hitbox */
  258.         160,8,  /* hit box width and height */
  259.         ITEMTEXT+ITEMENABLED+HIGHCOMP,  /* Item flags */
  260.         0,      /* each bit mutually-excludes a same-level Item */
  261.         (APTR)&MText4,  /* Item render  (IntuiText or Image or NULL) */
  262.         NULL,   /* Select render */
  263.         NULL,   /* alternate command-key */
  264.         NULL,   /* SubItem list */
  265.         MENUNULL        /* filled in by Intuition for drag selections */
  266. };
  267. #define MI_CROSSHAIR 2
  268.  
  269. struct IntuiText MText5 = {
  270.         3,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
  271.         0,0,    /* XY origin relative to container TopLeft */
  272.         NULL,   /* font pointer or NULL for default */
  273.         "ReDefine Plot",   /* pointer to text */
  274.         NULL    /* next IntuiText structure */
  275. };
  276.  
  277. struct MenuItem Gethowto = {
  278.         &Crosshair,     /* next MenuItem structure */
  279.         0,9,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  280.         160,8,  /* hit box width and height */
  281.         ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,  /* Item flags */
  282.         0,      /* each bit mutually-excludes a same-level Item */
  283.         (APTR)&MText5,  /* Item render  (IntuiText or Image or NULL) */
  284.         NULL,   /* Select render */
  285.         'd',    /* alternate command-key */
  286.         NULL,   /* SubItem list */
  287.         MENUNULL        /* filled in by Intuition for drag selections */
  288. };
  289. #define MI_GETHOWTO 1
  290.  
  291. struct IntuiText MText6 = {
  292.         3,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
  293.         0,0,    /* XY origin relative to container TopLeft */
  294.         NULL,   /* font pointer or NULL for default */
  295.         "Redraw",       /* pointer to text */
  296.         NULL    /* next IntuiText structure */
  297. };
  298.  
  299. struct MenuItem Redraw = {
  300.         &Gethowto,     /* next MenuItem structure */
  301.         0,0,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  302.         160,8,  /* hit box width and height */
  303.         ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,  /* Item flags */
  304.         0,      /* each bit mutually-excludes a same-level Item */
  305.         (APTR)&MText6,  /* Item render  (IntuiText or Image or NULL) */
  306.         NULL,   /* Select render */
  307.         'r',    /* alternate command-key */
  308.         NULL,   /* SubItem list */
  309.         MENUNULL        /* filled in by Intuition for drag selections */
  310. };
  311. #define MI_REDRAW 0
  312.  
  313. struct Menu Options = {
  314.         NULL,   /* next Menu structure */
  315.         137,0,  /* XY origin of Menu hit box relative to screen TopLeft */
  316.         75,0,   /* Menu hit box width and height */
  317.         MENUENABLED,    /* Menu flags */
  318.         "Options",      /* text of Menu name */
  319.         &Redraw      /* MenuItem linked list pointer */
  320. };
  321. #define M_OPTIONS 2
  322.  
  323. struct IntuiText MText7 = {
  324.         3,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
  325.         0,0,   /* XY origin relative to container TopLeft */
  326.         NULL,   /* font pointer or NULL for default */
  327.         "XY Region",    /* pointer to text */
  328.         NULL    /* next IntuiText structure */
  329. };
  330.  
  331. struct MenuItem Xyregion = {
  332.         NULL,   /* next SubItem structure */
  333.         97,24,   /* XY of Item hitbox relative to TopLeft of parent hitbox */
  334.         82,8,   /* hit box width and height */
  335.         ITEMTEXT+ITEMENABLED+HIGHCOMP,  /* Item flags */
  336.         0,      /* each bit mutually-excludes a same-level Item */
  337.         (APTR)&MText7,  /* Item render  (IntuiText or Image or NULL) */
  338.         NULL,   /* Select render */
  339.         NULL,   /* alternate command-key */
  340.         NULL,   /* no SubItem list for SubItems */
  341.         MENUNULL        /* filled in by Intuition for drag selections */
  342. };
  343. #define SI_XYREGION 2
  344.  
  345. UBYTE YTextOff[]="Y Region";
  346. UBYTE YTextOn[]= "YLock on";
  347.  
  348. struct IntuiText MText8 = {
  349.         3,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
  350.         0,0,   /* XY origin relative to container TopLeft */
  351.         NULL,   /* font pointer or NULL for default */
  352.         YTextOff,     /* pointer to text */
  353.         NULL    /* next IntuiText structure */
  354. };
  355.  
  356. struct MenuItem Yregion = {
  357.         &Xyregion,      /* next SubItem structure */
  358.         97,16,   /* XY of Item hitbox relative to TopLeft of parent hitbox */
  359.         82,8,   /* hit box width and height */
  360.         ITEMTEXT+ITEMENABLED+HIGHCOMP,  /* Item flags */
  361.         0,      /* each bit mutually-excludes a same-level Item */
  362.         (APTR)&MText8,  /* Item render  (IntuiText or Image or NULL) */
  363.         NULL,   /* Select render */
  364.         NULL,   /* alternate command-key */
  365.         NULL,   /* no SubItem list for SubItems */
  366.         MENUNULL        /* filled in by Intuition for drag selections */
  367. };
  368. #define SI_YREGION 1
  369.  
  370. UBYTE XTextOff[]="X Region";
  371. UBYTE XTextOn[]= "XLock on";
  372.  
  373. struct IntuiText MText9 = {
  374.         3,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
  375.         0,0,   /* XY origin relative to container TopLeft */
  376.         NULL,   /* font pointer or NULL for default */
  377.         XTextOff,     /* pointer to text */
  378.         NULL    /* next IntuiText structure */
  379. };
  380.  
  381. struct MenuItem Xregion = {
  382.         &Yregion,      /* next SubItem structure */
  383.         97,8,  /* XY of Item hitbox relative to TopLeft of parent hitbox */
  384.         82,8,   /* hit box width and height */
  385.         ITEMTEXT+ITEMENABLED+HIGHCOMP,  /* Item flags */
  386.         0,      /* each bit mutually-excludes a same-level Item */
  387.         (APTR)&MText9,  /* Item render  (IntuiText or Image or NULL) */
  388.         NULL,   /* Select render */
  389.         NULL,   /* alternate command-key */
  390.         NULL,   /* no SubItem list for SubItems */
  391.         MENUNULL        /* filled in by Intuition for drag selections */
  392. };
  393. #define SI_XREGION 0
  394.  
  395. struct IntuiText MText10 = {
  396.         3,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
  397.         0,0,    /* XY origin relative to container TopLeft */
  398.         NULL,   /* font pointer or NULL for default */
  399.         "Locks",        /* pointer to text */
  400.         NULL    /* next IntuiText structure */
  401. };
  402.  
  403. struct MenuItem Locks = {
  404.         NULL,   /* next MenuItem structure */
  405.         0,27,   /* XY of Item hitbox relative to TopLeft of parent hitbox */
  406.         122,8,  /* hit box width and height */
  407.         ITEMTEXT+ITEMENABLED+HIGHCOMP,  /* Item flags */
  408.         0,      /* each bit mutually-excludes a same-level Item */
  409.         (APTR)&MText10, /* Item render  (IntuiText or Image or NULL) */
  410.         NULL,   /* Select render */
  411.         NULL,   /* alternate command-key */
  412.         &Xregion,      /* SubItem list */
  413.         MENUNULL        /* filled in by Intuition for drag selections */
  414. };
  415. #define MI_LOCKS 3
  416.  
  417. struct IntuiText MText11 = {
  418.         3,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
  419.         0,0,    /* XY origin relative to container TopLeft */
  420.         NULL,   /* font pointer or NULL for default */
  421.         "Full Plot",    /* pointer to text */
  422.         NULL    /* next IntuiText structure */
  423. };
  424.  
  425. struct MenuItem Fullplot = {
  426.         &Locks,    /* next MenuItem structure */
  427.         0,18,   /* XY of Item hitbox relative to TopLeft of parent hitbox */
  428.         122,8,  /* hit box width and height */
  429.         ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,  /* Item flags */
  430.         0,      /* each bit mutually-excludes a same-level Item */
  431.         (APTR)&MText11, /* Item render  (IntuiText or Image or NULL) */
  432.         NULL,   /* Select render */
  433.         'f',    /* alternate command-key */
  434.         NULL,   /* SubItem list */
  435.         MENUNULL        /* filled in by Intuition for drag selections */
  436. };
  437.  
  438. #define MI_FULLPLOT 2
  439.  
  440. struct IntuiText MText12 = {
  441.         3,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
  442.         0,0,    /* XY origin relative to container TopLeft */
  443.         NULL,   /* font pointer or NULL for default */
  444.         "Slide",        /* pointer to text */
  445.         NULL    /* next IntuiText structure */
  446. };
  447.  
  448. struct MenuItem Slide = {
  449.         &Fullplot,     /* next MenuItem structure */
  450.         0,9,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  451.         122,8,  /* hit box width and height */
  452.         ITEMTEXT+ITEMENABLED+HIGHCOMP,  /* Item flags */
  453.         0,      /* each bit mutually-excludes a same-level Item */
  454.         (APTR)&MText12, /* Item render  (IntuiText or Image or NULL) */
  455.         NULL,   /* Select render */
  456.         NULL,   /* alternate command-key */
  457.         NULL,   /* SubItem list */
  458.         MENUNULL        /* filled in by Intuition for drag selections */
  459. };
  460. #define MI_SLIDE 1
  461.  
  462. struct IntuiText MText13 = {
  463.         3,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
  464.         0,0,    /* XY origin relative to container TopLeft */
  465.         NULL,   /* font pointer or NULL for default */
  466.         "Zoom", /* pointer to text */
  467.         NULL    /* next IntuiText structure */
  468. };
  469.  
  470. struct MenuItem Zoom = {
  471.         &Slide,     /* next MenuItem structure */
  472.         0,0,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  473.         122,8,  /* hit box width and height */
  474.         ITEMTEXT+ITEMENABLED+HIGHCOMP,  /* Item flags */
  475.         0,      /* each bit mutually-excludes a same-level Item */
  476.         (APTR)&MText13, /* Item render  (IntuiText or Image or NULL) */
  477.         NULL,   /* Select render */
  478.         NULL,   /* alternate command-key */
  479.         NULL,   /* SubItem list */
  480.         MENUNULL        /* filled in by Intuition for drag selections */
  481. };
  482. #define MI_ZOOM 0
  483.  
  484. struct Menu Edit = {
  485.         &Options, /* next Menu structure */
  486.         82,0,   /* XY origin of Menu hit box relative to screen TopLeft */
  487.         48,0,   /* Menu hit box width and height */
  488.         MENUENABLED,    /* Menu flags */
  489.         "Edit", /* text of Menu name */
  490.         &Zoom      /* MenuItem linked list pointer */
  491. };
  492. #define M_EDIT 1
  493.  
  494. struct IntuiText MText14 = {
  495.         3,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
  496.         0,0,    /* XY origin relative to container TopLeft */
  497.         NULL,   /* font pointer or NULL for default */
  498.         "Exit", /* pointer to text */
  499.         NULL    /* next IntuiText structure */
  500. };
  501.  
  502. struct MenuItem Quit = {
  503.         NULL,   /* next MenuItem structure */
  504.         0,27,   /* XY of Item hitbox relative to TopLeft of parent hitbox */
  505.         90,8,   /* hit box width and height */
  506.         ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,  /* Item flags */
  507.         0,      /* each bit mutually-excludes a same-level Item */
  508.         (APTR)&MText14, /* Item render  (IntuiText or Image or NULL) */
  509.         NULL,   /* Select render */
  510.         'e',    /* alternate command-key */
  511.         NULL,   /* SubItem list */
  512.         MENUNULL        /* filled in by Intuition for drag selections */
  513. };
  514. #define MI_QUIT 3
  515.  
  516. struct IntuiText MText15 = {
  517.         3,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
  518.         0,0,    /* XY origin relative to container TopLeft */
  519.         NULL,   /* font pointer or NULL for default */
  520.         "Print",        /* pointer to text */
  521.         NULL    /* next IntuiText structure */
  522. };
  523.  
  524. struct MenuItem Print = {
  525.         &Quit,    /* next MenuItem structure */
  526.         0,18,   /* XY of Item hitbox relative to TopLeft of parent hitbox */
  527.         90,8,   /* hit box width and height */
  528.         ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,  /* Item flags */
  529.         0,      /* each bit mutually-excludes a same-level Item */
  530.         (APTR)&MText15, /* Item render  (IntuiText or Image or NULL) */
  531.         NULL,   /* Select render */
  532.         'p',    /* alternate command-key */
  533.         NULL,   /* SubItem list */
  534.         MENUNULL        /* filled in by Intuition for drag selections */
  535. };
  536. #define MI_PRINT 2
  537.  
  538. struct IntuiText MText16 = {
  539.         3,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
  540.         0,0,    /* XY origin relative to container TopLeft */
  541.         NULL,   /* font pointer or NULL for default */
  542.         "IntroCAD",     /* pointer to text */
  543.         NULL    /* next IntuiText structure */
  544. };
  545.  
  546. struct MenuItem Introcad = {
  547.         NULL,   /* next SubItem structure */
  548.         65,40,  /* XY of Item hitbox relative to TopLeft of parent hitbox */
  549.         114,8,  /* hit box width and height */
  550.         ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,  /* Item flags */
  551.         0,      /* each bit mutually-excludes a same-level Item */
  552.         (APTR)&MText16, /* Item render  (IntuiText or Image or NULL) */
  553.         NULL,   /* Select render */
  554.         'c',    /* alternate command-key */
  555.         NULL,   /* no SubItem list for SubItems */
  556.         MENUNULL        /* filled in by Intuition for drag selections */
  557. };
  558. #define SI_ICAD 4
  559.  
  560. struct IntuiText MText17 = {
  561.         3,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
  562.         0,0,    /* XY origin relative to container TopLeft */
  563.         NULL,   /* font pointer or NULL for default */
  564.         "mCAD", /* pointer to text */
  565.         NULL    /* next IntuiText structure */
  566. };
  567.  
  568. struct MenuItem Mcad = {
  569.         &Introcad,      /* next SubItem structure */
  570.         65,32,  /* XY of Item hitbox relative to TopLeft of parent hitbox */
  571.         114,8,  /* hit box width and height */
  572.         ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,  /* Item flags */
  573.         0,      /* each bit mutually-excludes a same-level Item */
  574.         (APTR)&MText17, /* Item render  (IntuiText or Image or NULL) */
  575.         NULL,   /* Select render */
  576.         'm',    /* alternate command-key */
  577.         NULL,   /* no SubItem list for SubItems */
  578.         MENUNULL        /* filled in by Intuition for drag selections */
  579. };
  580. #define SI_MCAD 3
  581.  
  582. struct IntuiText MText18 = {
  583.         3,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
  584.         0,0,    /* XY origin relative to container TopLeft */
  585.         NULL,   /* font pointer or NULL for default */
  586.         "Draw", /* pointer to text */
  587.         NULL    /* next IntuiText structure */
  588. };
  589.  
  590. struct MenuItem Plot = {
  591.         &Mcad,      /* next SubItem structure */
  592.         65,24,   /* XY of Item hitbox relative to TopLeft of parent hitbox */
  593.         114,8,  /* hit box width and height */
  594.         ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,  /* Item flags */
  595.         0,      /* each bit mutually-excludes a same-level Item */
  596.         (APTR)&MText18, /* Item render  (IntuiText or Image or NULL) */
  597.         NULL,   /* Select render */
  598.         'd',    /* alternate command-key */
  599.         NULL,   /* no SubItem list for SubItems */
  600.         MENUNULL        /* filled in by Intuition for drag selections */
  601. };
  602. #define SI_DRAW 2
  603.  
  604. struct IntuiText MText19 = {
  605.         3,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
  606.         0,0,    /* XY origin relative to container TopLeft */
  607.         NULL,   /* font pointer or NULL for default */
  608.         "HPGL", /* pointer to text */
  609.         NULL    /* next IntuiText structure */
  610. };
  611.  
  612. struct MenuItem Hplg = {
  613.         &Plot,      /* next SubItem structure */
  614.         65,16,   /* XY of Item hitbox relative to TopLeft of parent hitbox */
  615.         114,8,  /* hit box width and height */
  616.         ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,  /* Item flags */
  617.         0,      /* each bit mutually-excludes a same-level Item */
  618.         (APTR)&MText19, /* Item render  (IntuiText or Image or NULL) */
  619.         NULL,   /* Select render */
  620.         'h',    /* alternate command-key */
  621.         NULL,   /* no SubItem list for SubItems */
  622.         MENUNULL        /* filled in by Intuition for drag selections */
  623. };
  624. #define SI_HPGL 1
  625.  
  626. struct IntuiText MText20 = {
  627.         3,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
  628.         0,0,    /* XY origin relative to container TopLeft */
  629.         NULL,   /* font pointer or NULL for default */
  630.         "IFF",  /* pointer to text */
  631.         NULL    /* next IntuiText structure */
  632. };
  633.  
  634. struct MenuItem Iff = {
  635.         &Hplg,      /* next SubItem structure */
  636.         65,8,  /* XY of Item hitbox relative to TopLeft of parent hitbox */
  637.         114,8,  /* hit box width and height */
  638.         ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,  /* Item flags */
  639.         0,      /* each bit mutually-excludes a same-level Item */
  640.         (APTR)&MText20, /* Item render  (IntuiText or Image or NULL) */
  641.         NULL,   /* Select render */
  642.         'i',    /* alternate command-key */
  643.         NULL,   /* no SubItem list for SubItems */
  644.         MENUNULL        /* filled in by Intuition for drag selections */
  645. };
  646. #define SI_IFF 0
  647.  
  648. struct IntuiText MText21 = {
  649.         3,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
  650.         0,0,    /* XY origin relative to container TopLeft */
  651.         NULL,   /* font pointer or NULL for default */
  652.         "Save", /* pointer to text */
  653.         NULL    /* next IntuiText structure */
  654. };
  655.  
  656. struct MenuItem Save = {
  657.         &Print,    /* next MenuItem structure */
  658.         0,9,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  659.         90,8,   /* hit box width and height */
  660.         ITEMTEXT+ITEMENABLED+HIGHCOMP,  /* Item flags */
  661.         0,      /* each bit mutually-excludes a same-level Item */
  662.         (APTR)&MText21, /* Item render  (IntuiText or Image or NULL) */
  663.         NULL,   /* Select render */
  664.         NULL,   /* alternate command-key */
  665.         &Iff,      /* SubItem list */
  666.         MENUNULL        /* filled in by Intuition for drag selections */
  667. };
  668. #define MI_SAVE 1
  669.  
  670. struct IntuiText MText22 = {
  671.         3,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
  672.         0,0,    /* XY origin relative to container TopLeft */
  673.         NULL,   /* font pointer or NULL for default */
  674.         "New",  /* pointer to text */
  675.         NULL    /* next IntuiText structure */
  676. };
  677.  
  678. struct MenuItem New = {
  679.         &Save,    /* next MenuItem structure */
  680.         0,0,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  681.         90,8,   /* hit box width and height */
  682.         ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,  /* Item flags */
  683.         0,      /* each bit mutually-excludes a same-level Item */
  684.         (APTR)&MText22, /* Item render  (IntuiText or Image or NULL) */
  685.         NULL,   /* Select render */
  686.         'n',    /* alternate command-key */
  687.         NULL,   /* SubItem list */
  688.         MENUNULL        /* filled in by Intuition for drag selections */
  689. };
  690. #define MI_NEW 0
  691. struct Menu Project = {
  692.         &Edit, /* next Menu structure */
  693.         0,0,    /* XY origin of Menu hit box relative to screen TopLeft */
  694.         75,0,   /* Menu hit box width and height */
  695.         MENUENABLED,    /* Menu flags */
  696.         "Project",      /* text of Menu name */
  697.         &New     /* MenuItem linked list pointer */
  698. };
  699. #define M_PROJECT 0
  700.  
  701.  
  702. /********/
  703. InitWind()
  704. {
  705.    newwindow.Screen = screen; window = OpenWindow(&newwindow);
  706.    rp = window->RPort; vp = &window->WScreen->ViewPort;
  707.    SetDrMd(rp,JAM1); SetAPen(rp,1);
  708.    SetMenuStrip(window,&Project); ShowTitle(screen,FALSE);
  709.    return(1);
  710. }
  711.  
  712.  
  713. /************/
  714. void CleanUp()
  715. {ClearMenuStrip(window); CloseWindow(window);}
  716.  
  717.  
  718. /************************/
  719. void AttrOnOff(Pict, item)
  720. struct Pict *Pict;
  721. int item;
  722. {
  723.    ClearMenuStrip(window);
  724.    switch(item) {
  725.    case SI_XREGION:
  726.       MText9.IText = (Pict->XRegionLock ? XTextOn : XTextOff);
  727.       break;
  728.    case SI_YREGION:
  729.       MText8.IText = (Pict->YRegionLock ? YTextOn : YTextOff);
  730.       break;
  731.    default: break;
  732.    }
  733.    SetMenuStrip(window, &Project);
  734. }
  735.  
  736.  
  737. /**************************************************************************/
  738. void PToU();
  739.  
  740. USHORT InvisPtr[] = {
  741.    0x0,0x0, 0x0,0x0, 0x0,0x0, 0x0,0x0, 0x0,0x0, 0x0,0x0, 0x0,0x0,
  742.    0x0,0x0, 0x0,0x0, 0x0,0x0, 0x0,0x0};
  743.  
  744. static short XHair = FALSE;
  745. static short WhiteBG = FALSE;
  746.  
  747. /*****************/
  748. void PutXHair(x,y)
  749. short x,y;
  750. {Move(rp,0,y); Draw(rp,MAXHORIZ,y); Move(rp,x,0); Draw(rp,x,MAXVERT);}
  751.  
  752. /**************************/
  753. void GetXHair(x,y)
  754. short *x, *y;
  755. {SetPointer(window,InvisPtr,9,9,0,0); SetDrMd(rp,COMPLEMENT); PutXHair(*x,*y);}
  756.  
  757. /***********************/
  758. void KillXHair(x,y)
  759. short x,y;
  760. {ClearPointer(window); PutXHair(x,y); SetDrMd(rp,JAM1);}
  761.  
  762. /*****************************/
  763. void RubberBox(x1, y1, x2, y2)
  764. short *x1, *y1, *x2, *y2;
  765. {
  766.    Move(rp,x1,y1);
  767.    if (XHair) {Draw(rp,x1,y2); Move(rp,x1,y1); Draw(rp,x2,y1);}
  768.    else {Draw(rp,x1,y2); Draw(rp,x2,y2); Draw(rp,x2,y1); Draw(rp,x1,y1);}
  769. }
  770.  
  771. #define NO_OBJECT 0
  772. #define REGION 1
  773. #define LINE 2
  774. #define BOX 3
  775. #define SLIDE 4
  776. extern USHORT chip WaitSprite[];
  777. extern int KEEP_GOING;
  778. extern char filename[150];
  779.  
  780.  
  781. /*************/
  782. CheckUser(Pict)
  783. struct Pict *Pict;
  784. {
  785.    ULONG class;
  786.    USHORT code;
  787.    static ULONG seconds, micros;
  788.    static ULONG Click_seconds=0, Click_micros=0;
  789.  
  790.    int retval = NOACTION, MouseMoved;
  791.    int screensave();
  792.    short x, y, x0, y0, x1, y1;
  793.    static short RubberObj = NO_OBJECT;
  794.    short RubberBand = FALSE;
  795.    FFP XMin, YMin, XMax, YMax;
  796.    struct PlotRegion *Reg;
  797.    struct Process  *OurTask;
  798.    struct Window   *old_pr_WindowPtr;
  799.    char plotname[150], def_drive[150], def_path[100], def_node[30],def_extn[20];
  800.    char Command[180];
  801.    char convert_tool[150];  /* string descibing path to current directory  */
  802.                             /* when started from workbench to locate tools */
  803.  
  804.    AttrOnOff(Pict, SI_XREGION);
  805.    AttrOnOff(Pict, SI_YREGION);
  806.    x = y = 0;
  807.    if (XHair) {SetDrMd(rp, COMPLEMENT); GetXHair(&x,&y); x1 = x; y1 = y;}
  808.    do {
  809.       Wait(1 << window->UserPort->mp_SigBit);
  810.  
  811.       while (msg = (struct IntuiMessage *) GetMsg(window->UserPort) ) {
  812.          class = msg->Class;
  813.          MouseMoved = (class == MOUSEMOVE);
  814.          code = msg->Code; x = msg->MouseX; y = msg->MouseY;
  815.          seconds=msg->Seconds; micros=msg->Micros;
  816.          ReplyMsg(msg);
  817.  
  818.          if ((class == MENUPICK) && (code != MENUNULL)) {
  819.             switch (MENUNUM(code)) {
  820.             case M_PROJECT:
  821.                switch(ITEMNUM(code)) {
  822.                case MI_QUIT:        KEEP_GOING=FALSE; retval = QUIT; break;
  823.                case MI_PRINT:       WrtPlt(Pict,FALSE); break;
  824.                case MI_NEW:         KEEP_GOING=TRUE; retval = QUIT; break;
  825.                case MI_SAVE:
  826.                   switch (SUBNUM(code)) {
  827.                   case SI_HPGL:
  828.                      WrtPlt(Pict,TRUE);
  829.                      break;
  830.                   case SI_MCAD:
  831.                      SetPointer(window,WaitSprite,26,14,-4,-4);
  832.                      To_mCAD(Pict,TRUE);
  833.                      ClearPointer(window);
  834.                      break;
  835.                   case SI_IFF:
  836.                      SetPointer(window,WaitSprite,26,14,-4,-4);
  837.                      screensave();
  838.                      ClearPointer(window);
  839.                      break;
  840.                   case SI_DRAW:
  841.                      SetPointer(window,WaitSprite,26,14,-4,-4);
  842.                      strcpy(plotname,filename);
  843.                      strsfn(plotname,def_drive,def_path,def_node,def_extn);
  844.                      strcat(def_drive,def_path);
  845.                      strcat(def_node,".draw");
  846.  
  847.                      OurTask = (struct Process *)FindTask(0L);
  848.                      old_pr_WindowPtr = (struct Window *)OurTask->pr_WindowPtr;
  849.                      OurTask->pr_WindowPtr = (APTR)window;
  850.                      if (get_fname(window,screen,"Save File As...",def_node,def_drive)==NULL)
  851.                           {
  852.                              OurTask->pr_WindowPtr = (APTR)old_pr_WindowPtr;
  853.                              ClearPointer(window);
  854.                              break;
  855.                            }
  856.  
  857.                      OurTask->pr_WindowPtr = (APTR)old_pr_WindowPtr;
  858.                      strmfp(plotname,def_drive,def_node);
  859.                      if (To_mCAD(Pict,FALSE))
  860.                        {
  861.                          strmfp(convert_tool,StartDir,"plot2draw");
  862.                          sprintf(Command,"\"%s\" t:tempfile \"%s\"",convert_tool,plotname);
  863.                          Execute(Command,0,0);
  864.                          DeleteFile("t:tempfile");
  865.                        }
  866.                      ClearPointer(window);
  867.                      break;
  868.                   case SI_ICAD:
  869.                      SetPointer(window,WaitSprite,26,14,-4,-4);
  870.                      strcpy(plotname,filename);
  871.                      strsfn(plotname,def_drive,def_path,def_node,def_extn);
  872.                      strcat(def_drive,def_path);
  873.                      strcat(def_node,".iCAD");
  874.  
  875.                      OurTask = (struct Process *)FindTask(0L);
  876.                      old_pr_WindowPtr = (struct Window *)OurTask->pr_WindowPtr;
  877.                      OurTask->pr_WindowPtr = (APTR)window;
  878.                      if (get_fname(window,screen,"Save File As...",def_node,def_drive)==NULL)
  879.                           {
  880.                              OurTask->pr_WindowPtr = (APTR)old_pr_WindowPtr;
  881.                              ClearPointer(window);
  882.                              break;
  883.                            }
  884.                      OurTask->pr_WindowPtr = (APTR)old_pr_WindowPtr;
  885.                      strmfp(plotname,def_drive,def_node);
  886.                      if (To_mCAD(Pict,FALSE))
  887.                        {
  888.                          strmfp(convert_tool,StartDir,"txt_2_icad");
  889.                          sprintf(Command,"\"%s\" t:tempfile \"%s\"",convert_tool,plotname);
  890.                          Execute(Command,0,0);
  891.                          DeleteFile("t:tempfile");
  892.                        }
  893.                      ClearPointer(window);
  894.                      break;
  895.                   default: break;
  896.                   }
  897.                   break;
  898.                default: break;
  899.                }
  900.                break;
  901.  
  902.             case M_EDIT:
  903.                switch (ITEMNUM(code)) {
  904.                case MI_ZOOM:        RubberObj = REGION; break;
  905.                case MI_SLIDE:       RubberObj = SLIDE; break;
  906.                case MI_FULLPLOT:    retval = GETDATALIMITS; break;
  907.                case MI_LOCKS:
  908.                   switch (SUBNUM(code)) {
  909.                   case SI_XYREGION:
  910.                      Pict->XRegionLock=Pict->YRegionLock=TRUE;
  911.                      AttrOnOff(Pict, SI_XREGION);
  912.                      AttrOnOff(Pict, SI_YREGION);
  913.                      break;
  914.                   case SI_YREGION:
  915.                      Pict->YRegionLock=!Pict->YRegionLock;
  916.                      AttrOnOff(Pict, SI_YREGION);
  917.                      break;
  918.                   case SI_XREGION:
  919.                      Pict->XRegionLock=!Pict->XRegionLock;
  920.                      AttrOnOff(Pict, SI_XREGION);
  921.                      break;
  922.                   default: break;
  923.                   }
  924.                   break;
  925.                default: break;
  926.                }
  927.                break;
  928.             case M_OPTIONS:
  929.                switch (ITEMNUM(code)) {
  930.                case MI_REDRAW:      retval = REDRAW; break;
  931.                case MI_CROSSHAIR:
  932.                   if (XHair = !XHair) {GetXHair(&x,&y); x1=x; y1=y;}
  933.                   else KillXHair(x1,y1);
  934.                   break;
  935.                case MI_GETHOWTO:     retval = GETHOWTO; break;
  936.                case MI_GRID:        Pict->Grid = !Pict->Grid; retval=REPLOT; break;
  937.                case MI_AXES:        Pict->Axes = !Pict->Axes; retval=REPLOT; break;
  938.                case MI_PALETTE:
  939.                   switch (SUBNUM(code)) {
  940.                   case SI_ALTERCOL:
  941.                      SetPointer(window,WaitSprite,26,14,-4,-4);
  942.                      DoColorWindow(screen, 150, 60, 1, TRUE);
  943.                      ClearPointer(window);
  944.                      break;
  945.                   case SI_SAVECOL:
  946.                      SetPointer(window,WaitSprite,26,14,-4,-4);
  947.                      SvColours();
  948.                      ClearPointer(window);
  949.                      break;
  950.                   default: break;
  951.                   }
  952.                   break;
  953.                default: break;
  954.                }
  955.                break;
  956.  
  957.             default: break;
  958.  
  959.             } /* switch */
  960.          } /* if ((class == MENUPICK) ...*/
  961.          else if (class == MOUSEBUTTONS) {
  962.                switch (code) {
  963.                case SELECTDOWN:
  964.                   if (RubberObj && !RubberBand)  /* BEGIN RUBBERBAND */
  965.                      {
  966.                        if ((x1!=x) || (y1!=y))
  967.                           {
  968.                              if (XHair) {PutXHair(x1,y1); PutXHair(x,y);}
  969.                           }
  970.                         RubberBand = TRUE; x0 = x1 = x; y0 = y1 = y;
  971.                         SetDrMd(rp,COMPLEMENT);
  972.                         if (RubberObj == REGION) {
  973.                            RubberBox(x0,y0,x,y);
  974.                         }
  975.                         else if (RubberObj == SLIDE) {
  976.                            Move(rp,x,y); Draw(rp,x,y);
  977.                         }
  978.                      }
  979.                     if  (DoubleClick(Click_seconds,Click_micros,seconds,micros))
  980.                       {
  981.                          if (RubberBand)
  982.                            {         /* zoom out X 2 */
  983.                              RubberBand = FALSE;
  984.                              if (RubberObj == REGION)
  985.                                 {
  986.                                   RubberBox(x0,y0,x1,y1);
  987.                                   Reg = Pict->CurrReg;
  988.                                   XMin = Reg->XMin - (Reg->XMax - Reg->XMin)/2;
  989.                                   XMax = Reg->XMax + (Reg->XMin - XMin);
  990.                                   YMin = Reg->YMin - (Reg->YMax - Reg->YMin)/2;
  991.                                   YMax = Reg->YMax + (Reg->YMin - YMin);
  992.                                   if ((!Pict->XRegionLock)&&( ( (FullReg->XMax-FullReg->XMin)/(XMax-XMin) )<100 ))
  993.                                       {Reg->XMin = XMin; Reg->XMax = XMax;}
  994.                                   if ((!Pict->YRegionLock)&&(((FullReg->YMax-FullReg->YMin)/(YMax-YMin))<100))
  995.                                       {Reg->YMin = YMin; Reg->YMax = YMax;}
  996.                                   retval = REPLOT;
  997.                                 }
  998.                              if (!XHair) SetDrMd(rp,JAM1);
  999.                            }
  1000.                       }
  1001.  
  1002.                   Click_seconds=seconds; Click_micros=micros;
  1003.                   break;
  1004.                case SELECTUP:  /* END RUBBERBAND */
  1005.                   if (RubberBand)
  1006.                     {
  1007.                       RubberBand = FALSE;
  1008.                       if (RubberObj == REGION) {
  1009.                           RubberBox(x0,y0,x1,y1);
  1010.                           Reg = Pict->CurrReg;
  1011.                           if ((abs(x-x0) > 2) && (abs(y-y0) > 2)) {
  1012.                              /* zoom in to new region */
  1013.                              PToU(Pict,min(x0,x),MAXVERT-max(y0,y),&XMin,&YMin);
  1014.                              PToU(Pict,max(x0,x),MAXVERT-min(y0,y),&XMax,&YMax);
  1015.                              if ((!Pict->XRegionLock)&&( ( (FullReg->XMax-FullReg->XMin)/(XMax-XMin) )<100 ))
  1016.                                {Reg->XMin = XMin; Reg->XMax = XMax;}
  1017.                              if ((!Pict->YRegionLock)&&(((FullReg->YMax-FullReg->YMin)/(YMax-YMin))<100))
  1018.                                {Reg->YMin = YMin; Reg->YMax = YMax;}
  1019.                              retval = REPLOT;
  1020.                           }
  1021.                        }
  1022.                        else if (RubberObj == SLIDE) {
  1023.                           Move(rp,x0,y0); Draw(rp,x1,y1);
  1024.                           PToU(Pict,x0,MAXVERT-y0,&XMin,&YMin);
  1025.                           PToU(Pict,x,MAXVERT-y,&XMax,&YMax);
  1026.                           Reg = Pict->CurrReg;
  1027.                           if (!Pict->XRegionLock)
  1028.                              {Reg->XMin += XMin-XMax; Reg->XMax += XMin-XMax;}
  1029.                           if (!Pict->YRegionLock)
  1030.                              {Reg->YMin += YMin-YMax; Reg->YMax += YMin-YMax;}
  1031.                           retval = REPLOT;
  1032.                        }
  1033.                        if (!XHair) SetDrMd(rp,JAM1);
  1034.                     }
  1035.                   break;
  1036.                default: break;
  1037.             } /* switch (code) */
  1038.             break;
  1039.          } /* else if (class == MENUBUTTONS) */
  1040.       } /* while */
  1041.  
  1042.       if (MouseMoved && ((x1!=x) || (y1!=y)))  {
  1043.          if (XHair)
  1044.                {PutXHair(x1,y1); PutXHair(x,y);}
  1045.          if (RubberBand) {
  1046.             if (RubberObj == REGION)
  1047.                {RubberBox(x0,y0,x1,y1); RubberBox(x0,y0,x,y);}
  1048.             else if (RubberObj == SLIDE)
  1049.                {Move(rp,x0,y0); Draw(rp,x1,y1); Move(rp,x0,y0); Draw(rp,x,y);}
  1050.          }
  1051.          x1 = x; y1 = y;
  1052.       }
  1053.    } while(retval == NOACTION);
  1054.  
  1055.    SetDrMd(rp, JAM1);
  1056.    return(retval);
  1057. }
  1058.